<!---GUI FOR NEW APPLICATION THRU EDTR--->
<!---BY MICO--->

<CFQUERY NAME = "getBROWSEFIELDS" datasource="#CLIENT.GLOBAL_DSN#">
		SELECT TABLENAME,COLUMNNAME,COLUMNDESC,FIELDGROUP,DEFAULTVALUE,DISPLAYFORMAT,
			COLUMNREQUIRED,SAMEROW,DISPLAYWIDTH,ISEDITABLEEFORM,COLUMNTYPE,PICKLIST,PHYSICALWIDTH,
			HINT,ISORGCHART
		FROM GRGBOSETABLEFIELDS
		WHERE TABLENAME = '#THETABLE#'
			AND ISVISIBLEEFORM = 'Y'
		ORDER BY COLUMNORDER
</CFQUERY>
<CFIF STRUCTKEYEXISTS(URL,"EDIT")>
	<CFSET THISDOCNUMBER = URL.EDIT>
	<CFQUERY NAME = "getENTRY" datasource="#CLIENT.COMPANY_DSN#">
		SELECT #VALUELIST(getBROWSEFIELDS.COLUMNNAME)#
		FROM #THETABLE#
		WHERE DOCNUMBER = '#THISDOCNUMBER#'
			AND PERSONNELIDNO = '#PID#'
			AND (APPROVED IS NULL OR APPROVED NOT IN ('Y','N','C'))
	</CFQUERY>
	<CFIF NOT getENTRY.RECORDCOUNT>
		<TR><TD colspan="100"><STRONG>YOU ARE TRYING TO ACCESS eFORMS ILLEGALLY! PLEASE USE THE STANDARD EDITOR TO AVOID BEING REPORTED FOR ILLEGAL USAGE.</STRONG></TD></TR><TR><TD colspan="100"><A href="javascript: history.back()">BACK TO PREVIOUS SCREEN</A></TD></TR>
		<cfabort>
	</CFIF>
<cfelse>
	<cfset getentry = querynew("#VALUELIST(getBROWSEFIELDS.COLUMNNAME)#")>
</CFIF>
<CFINCLUDE TEMPLATE="#client.common_path#popdate.cfm">
<script language="javascript">
function validateMasked(fld,msk) {

		var ln = msk.length,
		msk_=""
		x=0,y=0,
		fldVal = fld.value,
		fldNewVal="",
		mskChr="",nValue=0,nAscii=0,sType="",sep="",sTmp="",sTmpVal="";
		for(x=0;x<msk.length;x++) {
		mskChr = msk.charAt(x);
		nValue=parseInt(mskChr);

		if (mskChr == "#") {
			sType = "D";
		}}}
function ShowCalendar(FormName, FieldName) {
				quickpopdate(FormName, FieldName)
		}
	function ShowLookup(level,tblname, frmfldcode, formname, fld2disp, fldcode, frmflddesc, flddesc) 									{
					<CFOUTPUT>
						open("#client.common_path#poplookup.cfm" +
					</CFOUTPUT>
						"?tl=" + level +
						"&tn=" + tblname +
						"&fn=" + frmfldcode +
						"&frm=" + formname +
						"&fldprop=" + fld2disp +
						"&fldfn=" + fldcode +
						"&desc=" + frmflddesc +
						"&flddesc=" + flddesc,
						"LookupWindow", "width=660,height=330,ScrollBars=Yes,Resizable=Yes")
				}
					function getvalue(level,tblname, frmfldcode, formname, fld2disp, fldcode, frmflddesc, flddesc,svalue) 									{
					<CFOUTPUT>
						open("#client.common_path#locate.cfm" +
					</CFOUTPUT>
						"?tl=" + level +
						"&tn=" + tblname +
						"&fn=" + frmfldcode +
						"&frm=" + formname +
						"&fldprop=" + fld2disp +
						"&fldfn=" + fldcode +
						"&desc=" + frmflddesc +
						"&flddesc=" + flddesc +
						"&svalue=" + svalue,
						"LookupWindow", "width=660,height=330,ScrollBars=Yes,Resizable=Yes")
				}
</script>
<CFMODULE template="#CLIENT.COMMON_PATH#cfm_geturlvariables.cfm" REMOVEURL = "EDIT,t">
<CFFORM METHOD="post" NAME="frmNEWAPP" <!---action="#getfilefrompath(getbasetemplatepath())#?#URLVARIABLES#&t=#thetable#"--->> 
	<TABLE BORDER=0 CELLPADDING=2 CELLSPACING=2 BGCOLOR="#client.color_tblhead#" WIDTH="100%" HEIGHT=33>
		<TR>
			<TD CLASS="white" NOWRAP>
				&nbsp;
				<CFINPUT TYPE="submit" NAME="btnSAVENEWAPP"  VALUE="Save" CLASS="bitbtn" validate="submitonce" >
				<CFINPUT type="button" NAME="Cancel" VALUE="Back" CLASS="bitbtn" onclick="javascript: history.back()">
				<CFINPUT type="hidden" NAME="formPID" VALUE="#PID#">
				<CFINPUT type="hidden" NAME="formtable" VALUE="#thetable#">
				<CFINPUT type="hidden" NAME="formformcode" VALUE="#theformcode#">
		</TR>
	</TABLE>
	<HR>
	<TABLE BORDER=0 CELLPADDING=0 CELLSPACING=5 WIDTH="100%">
		<CFOUTPUT>
		<TR VALIGN="bottom">
			<TD ALIGN="right"><IMG SRC="#client.image_path##session.site_ibose#"></TD>
			<TD NOWRAP CLASS="bold14" WIDTH="100%"><FONT FACE="Impact" SIZE="+2">#client.companyname#</FONT><BR>#THETITLE#</TD>
		</TR>
		</CFOUTPUT>
	</TABLE>
	<TABLE BORDER=0 CELLSPACING=3 CELLPADDING=0 WIDTH="100%" BGCOLOR="#FFFFFF">
	<cfoutput>
	<cfloop query="getbrowsefields">
	<tr height="5"></tr>
			<TR>
				<cfset sEntryVal=evaluate("getentry.#COLUMNNAME#")>
				<cfset thecolumnname = columnname>
				<cfset mask = "">
				<cfset thedf = displayformat>
				<cfif displayformat neq "">
					<cfloop index="pos" from="1" to="#len(displayformat)#">
						<cfif mid(thedf,pos,1) eq "##">
							<cfset mask = mask &"9">
						<cfelse>
							<cfset mask = mask &"#mid(thedf,pos,1)#">
						</cfif>
					</cfloop>
				</cfif>
				<CFQUERY DATASOURCE="#client.global_dsn#" NAME="autogen">
					SELECT *
					FROM GSTAUTOGENFIELD
					WHERE TABLENAME = '#THETABLE#' AND
						  FIELDNAME = '#COLUMNNAME#'
				</CFQUERY>
				<CFIF autogen.RecordCount>
					<CFSET lAutoGen="Yes">
					<cfif not structkeyexists(url,"edit")>
						<CFMODULE TEMPLATE="#client.common_path#autogenfield.cfm"
								SEEDKEY="#autogen.SEEDKEY#"
								CODELENGTH="#autogen.CODELENGTH#"
								COLUMNNAME="#getBROWSEFIELDS.COLUMNNAME#"
								TABLENAME_FK="#THETABLE#"
								DATASOURCE="#CLIENT.COMPANY_DSN#"
								WITHDATE="#autogen.WITHDATE#">
							<CFSET sEntryVal=AUTOGENVALUE>
							<cfset readonly = "readonly">
					<cfelse>
						<cfset readonly = "readonly">
					</cfif>
				<CFELSE>
					<CFSET lAutoGen="No">
					<cfset readonly="">
				</CFIF>
				
				<TD width="150" align="right" >#COLUMNDESC#:&nbsp;<CFIF COLUMNREQUIRED EQ "Y"> * <cfset req="yes"><cfelse><cfset req="no"></CFIF></TD>
				<TD align="left">
					<CFIF #COLUMNTYPE# EQ "ftdatetime">
						<cfif structkeyexists(form,"refdate")>
							<cfset sentryval = form.refdate>
						<cfelseif structkeyexists(url,"edit")>
							<cfset sentryval = dateformat(evaluate("getentry.#columnname#"),"MM/DD/YYY")>
						<cfelse>
							<cfif sentryval eq "01/01/1900">
								<cfset sentryval = "">
							</cfif>
						</cfif>
						<CFINPUT TYPE="text" NAME="edt#COLUMNNAME#"
							SIZE="15" MAXLENGTH="10" readonly = "y" required="#req#" VALUE="#sentryval#" message="Please enter a proper value for #columndesc#"  validate="date" validateat="onsubmit,onserver"
						onkeyup="CheckDigit('0123456789/', this)"
						ondblclick="GetLastInput(this)" >
						<A HREF="javascript:ShowCalendar('frmNEWAPP','edt#COLUMNNAME#');">
						<IMG SRC="#client.icon_path#calendar.gif"  BORDER="0" ALT="View Calendar" >
						</A>
					<cfelseif #columntype# eq "ftInteger">
						<CFINPUT TYPE="text" NAME="edt#COLUMNNAME#"
						SIZE="#displaywidth#" MAXLENGTH="#physicalwidth#"
						VALUE="#sEntryVal#" ALIGN="RIGHT" required="#req#"
						  validate="integer" validateat="onsubmit,onserver" message="Please enter a proper value for #columndesc#">
					<cfelseif #columntype# eq "ftFloat">
						<CFINPUT TYPE="text" NAME="edt#COLUMNNAME#"
						SIZE="#displaywidth#" MAXLENGTH="#physicalwidth#"
						VALUE="#sEntryVal#" ALIGN="RIGHT" required="#req#"
						  validate="float" validateat="onsubmit,,onserver" message="Please enter a proper value for #columndesc#">
					<!---added by mico ftmemo--->
					<cfelseif #columntype# eq "ftMemo">
						<CFTEXTAREA COLS="#DISPLAYWIDTH#" ROWS="4" NAME="edt#COLUMNNAME#" required="#req#" message="Please enter a proper value for #columndesc#"><cfif structkeyexists(url,"edit")>#sentryval#</cfif></CFTEXTAREA>
					<CFELSEIF LEN(PICKLIST) LT 1>
						<!---NO PICKLIST--->
						<!--- Check if there's a lookup --->
						<CFQUERY NAME="GetLookup" DATASOURCE="#client.global_dsn#">
							SELECT A.*, B.LEVELID
							FROM GSTLOOKUP A, GRGBOSETABLE B
							WHERE
								(A.MASTERTABLE = '#thetable#') AND
								(A.MASTERFIELD = '#COLUMNNAME#') AND
								(A.LOOKUPTABLE = B.TABLENAME)
						</CFQUERY>
						<CFIF GetLookup.RecordCount>
							<CFIF (#trim(GetLookup.LEVELID)# IS "") OR
								(#trim(GetLookup.LOOKUPKEYFIELD)# IS "") OR
								(#trim(GetLookup.LOOKUPRESULTFIELD)# IS "") OR
								(#trim(GetLookup.LOOKUPTABLE)# IS "")>
								<I>*Lookup not properly setup.</I>
							<CFELSE>
								<!--- get the description in the lookup --->
	
								<!--- get table location --->
								<!--- custom tag: parameter: DBLEVEL; return value: DSN --->
								<CFMODULE TEMPLATE="#client.common_path#cfm_leveldsn.cfm" DBLEVEL="#GetLookup.LEVELID#">
								<CFSET lk_dsn = DSN>
	
								<CFQUERY NAME="GetLkDesc" DATASOURCE="#lk_dsn#">
									SELECT #GetLookup.LOOKUPRESULTFIELD#
									<CFIF Trim(GetLookup.EXTRARESULTFLD) NEQ "">
										,#GetLookup.EXTRARESULTFLD#
									<CFSET lWithExtra=true>
									</CFIF>
									FROM #GetLookup.LOOKUPTABLE#
									WHERE
										(#GetLookup.LOOKUPKEYFIELD# = '#sEntryVal#')
								</CFQUERY>
									<INPUT TYPE="text" NAME="edt#COLUMNNAME#"
									<!---modified by mico 12162009--->
									<CFIF structkeyexists (url,"edit")>
									VALUE="#sEntryVal#"readonly="Y"
									<CFELSE>
									VALUE="" readonly = "Y"
									</CFIF>
									onblur="getvalue('#trim(GetLookup.LEVELID)#','#trim(GetLookup.LOOKUPTABLE)#','edt#COLUMNNAME#','frmNEWAPP',<cfif getlookup.extraresultfld eq "">'#GetLookup.LOOKUPKEYFIELD#~#GetLookup.LOOKUPKEYFIELD#~ftString,#GetLookup.LOOKUPRESULTFIELD#~#GetLookup.LOOKUPRESULTFIELD#~ftString'<cfelse>'#GetLookup.LOOKUPKEYFIELD#~#GetLookup.LOOKUPKEYFIELD#~ftString,#GetLookup.LOOKUPRESULTFIELD#~#GetLookup.LOOKUPRESULTFIELD#~ftString<cfloop list="#getlookup.extraresultfld#" index="y">,#y#~#y#~ftString,#y#~#y#~ftString </cfloop>'</cfif>,'#trim(GetLookup.LOOKUPKEYFIELD)#',<cfif getlookup.extraresultfld eq "">'lk#COLUMNNAME#'<cfelse>'lk#COLUMNNAME#<cfloop list="#getlookup.extraresultfld#" index="a">,edt#a#</cfloop>'</cfif>,<cfif getlookup.extraresultfld eq "">'#trim(GetLookup.LOOKUPRESULTFIELD)#'<cfelse>'#trim(GetLookup.LOOKUPRESULTFIELD)#<cfloop list="#getlookup.extraresultfld#" index="a">,#a#</cfloop>'</cfif>,this.value)"
									>
									<A HREF="javascript:ShowLookup('#trim(GetLookup.LEVELID)#','#trim(GetLookup.LOOKUPTABLE)#','edt#COLUMNNAME#','frmNEWAPP',<cfif getlookup.extraresultfld eq "">'#GetLookup.LOOKUPKEYFIELD#~#GetLookup.LOOKUPKEYFIELD#~ftString,#GetLookup.LOOKUPRESULTFIELD#~#GetLookup.LOOKUPRESULTFIELD#~ftString'<cfelse>'#GetLookup.LOOKUPKEYFIELD#~#GetLookup.LOOKUPKEYFIELD#~ftString,#GetLookup.LOOKUPRESULTFIELD#~#GetLookup.LOOKUPRESULTFIELD#~ftString<cfloop list="#getlookup.extraresultfld#" index="y">,#y#~#y#~ftString,#y#~#y#~ftString </cfloop>'</cfif>,'#trim(GetLookup.LOOKUPKEYFIELD)#',<cfif getlookup.extraresultfld eq "">'lk#COLUMNNAME#'<cfelse>'lk#COLUMNNAME#<cfloop list="#getlookup.extraresultfld#" index="a">,edt#a#</cfloop>'</cfif>,<cfif getlookup.extraresultfld eq "">'#trim(GetLookup.LOOKUPRESULTFIELD)#'<cfelse>'#trim(GetLookup.LOOKUPRESULTFIELD)#<cfloop list="#getlookup.extraresultfld#" index="a">,#a#</cfloop>'</cfif>)"><IMG SRC="#client.icon_path#lookup.gif" BORDER="0" ALT="Select from Lookup" ALIGN="bottom"></A>
									<INPUT TYPE="text" NAME="lk#COLUMNNAME#"
									<!---modified by mico 12162009--->
									<CFIF structkeyexists (url,"edit")>
									VALUE="#evaluate("GetLkDesc." & GetLookup.LOOKUPRESULTFIELD)#" SIZE="50" readonly="Y"
									<CFELSE>
									VALUE="" readonly = "Y"
									</CFIF>
									>
								</CFIF>						
						<CFELSE>
							<CFINPUT TYPE="text" NAME="edt#COLUMNNAME#"
						SIZE="#displaywidth#" MAXLENGTH="#physicalwidth#"
						VALUE="#sEntryVal#" ALIGN="RIGHT" required="#req#" message="Please enter a proper value for #columndesc#"
						  mask="#mask#" readonly="#readonly#">
						</CFIF>
					<!---MICO 01272010 FOR PICKLIST--->
					<!---START--->
					<CFELSE>
						<!---THERE IS A PICKLIST--->
						<CFIF ListLen(PICKLIST) LTE 3>
							<CFLOOP INDEX="x" LIST="#PICKLIST#">
								<INPUT NAME="edt#COLUMNNAME#" <CFIF x EQ sEntryVal or sentryval eq "">checked="checked"</CFIF> TYPE="radio" VALUE="#x#" >#x#
							</CFLOOP>
						<CFELSE>
							<SELECT NAME="edt#COLUMNNAME#">
								<OPTION VALUE="">&nbsp;&nbsp;&nbsp;&nbsp;</OPTION>
								<CFLOOP INDEX="ListElement" LIST="#PICKLIST#" DELIMITERS=",">
										<CFIF sEntryVal EQ ListElement or sentryval eq "">
											<OPTION SELECTED = "SELECTED" VALUE="#ListElement#">#ListElement#</OPTION>
										<CFELSE>
											<OPTION VALUE="#ListElement#">#ListElement#</OPTION>
										</CFIF>							
								</CFLOOP>
							</SELECT>								
						</CFIF>
					</CFIF>
	</TD>
	</TR>
	</cfloop>
	</cfoutput>
	<CFIF STRUCTKEYEXISTS(URL,"EDIT")>
		<cfinput type="hidden" value="#THISDOCNUMBER#" name="hidEDIT">
	</CFIF>
	</CFFORM>
	</TABLE>
	<HR>
	<I>* - Field that requires a value.</I>
</TD>
</TR>
</TABLE>
